const SYS_INFO = uni.getSystemInfoSync();
// 安全高度（留海屏）单位px
export const getStatusBarHeight = () => SYS_INFO.statusBarHeight || 15;

// 获取胶囊按钮的高度h5 app没有，那就返回固定值
export const getTitleBarHeight = () => {
	// 默认标题栏高度
	const defaultHeight = 40;

	// 微信小程序环境下获取标题栏高度
	if (uni.getMenuButtonBoundingClientRect) {
		const menuButton = uni.getMenuButtonBoundingClientRect();
		const {
			top,
			height,
		} = menuButton;
		// 计算并返回微信小程序环境下的标题栏高度
		return height + (top - getStatusBarHeight()) * 2;
	}

	// 非微信小程序环境，直接返回默认高度
	return defaultHeight;
};


export const getNavBarHeight = () => getStatusBarHeight() + getTitleBarHeight();